import axios from 'axios'
import config from '../config/index'
import { Toast } from 'vant'
import Vue from 'vue'
Vue.use(Toast)

const { api: {
  devApiBaseUrl, proApiBaseUrl
}} = config

const BaseUrl = process.env.NODE_ENV === 'production' ? proApiBaseUrl : devApiBaseUrl;


export const Service = axios.create({
  baseURL: BaseUrl,
  timeout: 8000,
  method: 'post',
  headers: {
      // 'Content-Type': 'application/json;charset=UTF-8'
      'Content-Type': 'application/x-www-form-urlencoded'
  }
})


Service.interceptors.request.use((config) => {
  return config;
}, (err) => {
  return Promise.reject(err)
})

Service.interceptors.response.use((res) => {
  return res
}, (err) => {
  return Promise.reject(err)
})